package cn.itcast.day02.demo;

import com.sun.org.apache.xpath.internal.objects.XString;

public class text02 {

    public static void main(String[] args) {

        /*System.out.println(isSame(10,10));
        System.out.println(isSame(10,20));
        System.out.println(getsum());
        printskill(5);
        System.out.println(sum(10,20));
        System.out.println(sum(10,20,30));
        System.out.println(sum(10,20,30,40));
        short a = 10;
        short b = 20;
        isSameKind(a,b);*/

        //数组格式： 数据类型[]数组名称 = new 数据类型[数组长度]
        //动态初始化-直接指定数组当中的元素个数
        int[] arrayA = new int [300];
        double[] arrayB = new double[10];
        String[] arrayC = new String[5];
        //静态初始化
        //数据类型[]数组名称 = new数据类型[]{元素1，元素2，...}
        int[] arrayE = new int[]{10,20};
        String[] arrayF = new String[]{"java","hello"};
        //省略格式
        int[] arrayG = {1,2,3};
        int[] arrayH;
        arrayH = new int[]{11,22,33};
        System.out.println(arrayE[1]);
    }

    /*public static int sum (int a, int b){
        int result = a + b;
        return  result;
    }
    public static void method1() {
        for (int i = 1; i < 11; i++){
            System.out.println(i);
        }
    }*/
    //定义一个方法，用来判断两个数字是否相等
    public static boolean isSame(int a,int b) {
       /* boolean same;
        if (a == b) {
            same = true;
        }else{
            same = false;
        }*/

      //boolean same = a==b?true:false;
        // boolean same = a == b;

        return a == b;
    }

    //定义一个方法，用来求出1~100之间所有数字的和值
    public static int getsum(){
        int a = 0;
        for (int i = 1; i < 101; i++) {
            a += i;
        }
        return a;
    }

    //打印指定次数的HelloWorld
    public static void printskill(int a) {
        for (int i = 0; i < a; i++) {
            System.out.println("helloworld"+ (i+1));
        }
    }

    //方法重载(方法重载只与方法名和参数名称有关)
    public static int sum(int a, int b) {
        return a+b;
    }
    public static int sum(int a, int b,int c) {
        return a+b+c;
    }
    public static int sum(int a, int b,int c, int d) {
        return a+b+c+d;
    }

    //比较两个数字是否相等
    //参数类型分别为两个byte。两个short，两个int
    public static boolean isSameKind(int a,int b) {
        System.out.println("两个int类型");
        return a==b;
    }
    public static boolean isSameKind(byte a,byte b) {
        System.out.println("两个byte类型");
        return a==b;
    }
    public static boolean isSameKind(short a,short b) {
        System.out.println("两个short类型");
        return a==b;
    }
}
